// 教师对象
class Teacher extends User {
    def grailsApplication 

    static hasMany = [ course : String ,  organize:Organize]
     
    String name = ''
    String sex = ''
    String NO = ''
    Date birthday
    String staff = ''
    String degree = ''
    String features = ''
    boolean state = false;//在校、离校状态    true为离校
    boolean hasBlog = false;
    String source = ''
    School school

    static constraints = {
        name(size: 1..50, blank: false);
        sex(size: 1..4,blank: false)
        NO(size: 1..25, blank: true)
        birthday()
        degree(blank: true) //学历
        staff(blank: true) // 职称
        features(blank: true) // 政治面貌
        state()
        source(size: 1..1000)
        school(nullable:true)
    }
    
    static mapping = {
       table 'xedu_teacher'
    }

    String toString() {
        "${name}"
    }

    String escpeName() {
        if (username.indexOf(grailsApplication.config.grails.default.username.segment) > -1) { 
            username.substring(0,username.indexOf(grailsApplication.config.grails.default.username.segment))
        }else{
            username
        }
    }
}
